<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>出行规划</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="css/all_css.css" />
		<link rel="stylesheet" type="text/css" href="css/weui/base.css" />
		<link rel="stylesheet" type="text/css" href="lib/weui.css" />
		<link rel="stylesheet" type="text/css" href="css/weui/jquery-weui.css" />
		<link rel="stylesheet" type="text/css" href="iconfont/iconfont.css" />
		
		<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=MMh4H9m5FLBpizlht86GnGynuaM0oGKz"></script>
	</head>

	<body ontouchstart>

		<div class="mask opacity" id="opacityDiv" style="display: none;">
			<div id="tcLoading" style="display: none;">
				努力加载中...
			</div>
		</div>
		<div class="cxgh_main" id="cxgh_all">
			<div class="cxgh_head">
				<div class="app_head_left">
					<a class="iconfont" id="returnBtn_cxgh">&#xe6d4;</a>
				</div>
				<div class="app_head_mid">
					<p id="app_head_title">出行规划</p>
				</div>
			</div>
			<div id="l-map">

			</div>
			<div class="placeInput">
				<div class="placeInput_mid">
					<input type="text" name="" id="suggestId_end" placeholder="输入目的地" />
					<input type="hidden" id="suggestId_end_hidden" value="" />
					<div id="collectionBtn">
						<i id="taoxin" class="iconfont">&#xe649;</i><span style="color: #FF0000; display: none;" class="f12" id="taoxinLabel">可收藏</span>
					</div>
				</div>
				<div class="placeInput_right">
					<a class="iconfont" id="research_btn" href="javascript:;">&#xe709;</a>
				</div>
			</div>
			<div id="cxgh_footer">
				<li>
					<a href="index01.html">
						<img src="img/cxgh/returnIndexBtn.png" style="width: 30px;" id="returnIndexPic" />
						<label id="returnIndexLable">回首页<label>
				   </a>
			    </li>
				<li>
					<a href="cxgh_line.html">
						<img src="img/cxgh/Icon_line.png" class="iconFoot" />
						<label>查公交<label>
				    </a>
			    </li>
			    <li>
				    <a href="subway.html" style="border: none;">
					    <img src="img/cxgh/Icon_subway.png" class="iconFoot" />
					    <label>查地铁</label>
					</a>
				</li>
			</div>
		</div>
		<!--<iframe id="cxghIframe" name="cxgh" src="" width="100%" height="100%" style="display: none;"></iframe>-->

		<script src="js/jquery-1.11.0.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/md5.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/weui/jquery-weui.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/back_end.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript" charset="UTF-8">
			//			document.body.addEventListener("DOMMouseScroll", function(event) {
			//				console.log("a");
			//			});

			//			document.body.addEventListener('touchmove',function(event){
			//				document.activeElement.blur();
			//			});

			//★★★★★★★★★★★★★★★★★★★★★★★★
			//★★★★★点击查询按钮搜索路线（最新）★★★
			//★★★★★★★★★★★★★★★★★★★★★★★★
			$("#research_btn").click(function() {
				if($("#suggestId_start").val() == "" && $("#suggestId_start").attr("placeholder") == "输入起点" || $("#suggestId_end").val() == "") {
					$.alert("请您输入目的地", "提示");
				} else {

					var mdd = $("#suggestId_end").val(); //目的地
					// 设置目标位置坐标点和其实位置坐标点
					//                  var dst = new plus.maps.Point(116.39131928,39.90793074); // 天安门 
					//                  var src = new plus.maps.Point(116.335,39.966); // 大钟寺
					// 调用系统地图显示 
					//                  plus.maps.openSysMap( dst, "天安门", src );
					// H5 plus事件处理

					if(window.plus) {
						plusReadyAz(mdd);
					} else {
						document.addEventListener("plusready", plusReady, false);
					}

				}

			});

		

			function plusReadyAz(mdd) {

				//						alert(mdd)
				plus.maps.Map.geocode(mdd, {
					city: ""
				}, function(event) {
					var address = event.address; // 转换后的地理位置
					var point = event.coord; // 转换后的坐标信息
					var coordType = event.coordType; // 转换后的坐标系类型
					var dst = var dst = new plus.maps.Point(116.39131928,39.90793074);//起点
					var src = new plus.maps.Point(116.335,39.966);//终点
					// 调用系统地图显示
					plus.maps.openSysMap(dst, mdd, src);
				}, function(e) {
					$.alert("连接超时，请稍候再试","提示");
				});
			}

			//得到当前位置json字符串信息 及经纬度坐标 海拔 移动 移动速度的方法
			function geoInf(position) {
				var addressStr = position.addresses;
				var codns = position.coords; //获取地理坐标信息；
				var lat = codns.latitude; //获取到当前位置的纬度；
				x = lat;
				var longt = codns.longitude; //获取到当前位置的经度
				y = longt;
				//								alert(addressStr);
				//				$("#jbPlace").val(addressStr);
				//				console.log('------定位-----' + addressStr);

			}
			// 通过定位模块获取位置信息
			function getGeocode() {
				plus.geolocation.getCurrentPosition(geoInf, {
					geocode: true
				});
			}

			$("#returnBtn_cxgh").click(function() {
				window.location.href = "javascript:history.go(-1)";
			});
			//javascript:history.go(-1)
			//		function returnBtn_cxgh(){
			//			if(document.getElementById("cxghIframe").style.display=="block")
			//		};
			var zdAddress = "";
			// 百度地图API功能
			var map = new BMap.Map("l-map");
			map.centerAndZoom(new BMap.Point(125.331505, 43.959007), 12);
			var ac_1 = new BMap.Autocomplete;
			var ac_2 = new BMap.Autocomplete;

			//获取我的位置方法
			function getMyPosition(zdAddress) {
				//获取我的位置
				var geolocation = new BMap.Geolocation();
				geolocation.getCurrentPosition(function(r) {
					if(this.getStatus() == BMAP_STATUS_SUCCESS) {
						var mk = new BMap.Marker(r.point);
						map.addOverlay(mk);
						map.panTo(r.point);
						//收藏地点地址解析
						// 创建地址解析器实例
						var myGeo = new BMap.Geocoder();
						// 将地址解析结果显示在地图上,并调整地图视野
						myGeo.getPoint(zdAddress, function(point) {
							if(point) {
								map.centerAndZoom(point, 16);
								map.addOverlay(new BMap.Marker(point));
								//console.log(point.lng + "，" + point.lat);
								//根据起终点坐标查询我的位置-我收藏的地点的线路规划
								var p1 = new BMap.Point(r.point.lng, r.point.lat);
								var p2 = new BMap.Point(point.lng, point.lat);
								var transit = new BMap.TransitRoute(map, {
									renderOptions: {
										map: map,
										panel: "myResult",
									}
								});
								transit.search(p1, p2);

								//$("#tangram-suggestion--TANGRAM__1z-main").hide();
							} else {
								$.alert("您选择的地址没有解析到结果");
							}
						}, "吉林省");

					} else {
						//alert('failed' + this.getStatus());
					}
				}, {
					enableHighAccuracy: true
				})
			};

			$(function() {
				var h = window.screen.availHeight;
				$("#cxgh_all").height(h - 55);
				$("#l-map").height(h - 70 - 55);
				if(document.documentElement.clientWidth <= 320) {
					$("#taoxinLabel").css("font-size", "0.75em");
					$("#taoxin").css("font-size", "1.2em");
				}
				var urlStr = "" + window.location;
				if(urlStr.indexOf("?dz=") != -1) {
					//当url地址中有"?"时（从我的收藏跳转至出行规划）
					urlStr = decodeURI(urlStr);
					//										console.log(urlStr);
					var collectAddress = urlStr.split("dz=")[1];
					zdAddress = collectAddress; //终点字符串地址赋值为收藏的目的地字符串
					//为终点输入框赋值
					$(document).ready(function() {
						$("#suggestId_end").val(zdAddress);
						redTaoxin();
					});
					//				document.getElementById("suggestId_end").value=collectAddress;
					//					hasCollected();
					//					getMyPosition(collectAddress);
					//					//					$("#suggestId_end").val(collectAddress);
					//					$("#app_head_title").click();

					setTimeout(function() {
						$("#research_btn").click();
					}, 1000);
				} else if(urlStr.indexOf("?sta") != -1) {
					//地图展示（火车）到这去点击跳转至出行规划
					urlStr = decodeURI(urlStr);
					var str = urlStr.split("?sta=")[1];
					//					console.log(urlStr);
					var pointStr = str.split("&name=")[0];
					var staNameStr = str.split("&name=")[1];
					//					console.log(pointStr);
					var staPoint = new BMap.Point(pointStr.split("%20")[0], pointStr.split("%20")[1]);
					//					console.log(staNameStr);
					zdAddress = staNameStr; //终点字符串地址赋值为收藏的目的地字符串
					//为终点输入框赋值
					$(document).ready(function() {
						$("#suggestId_end").val(zdAddress);
					});
					setTimeout(function() {
						$("#research_btn").click();
					}, 1000);
				} else if(urlStr.indexOf("?boatEndP=") != -1) {
					//地图展示（水运）到这去点击跳转至出行规划
					urlStr = decodeURI(urlStr);
					var str = urlStr.split("?boatEndP=")[1];
					//					console.log(str);
					//为终点输入框赋值
					$(document).ready(function() {
						$("#suggestId_end").val(str);
					});
					setTimeout(function() {
						$("#research_btn").click();
					}, 1000);
				} else if(urlStr.indexOf("?bus=") != -1) {
					var str = urlStr.split("?bus=")[1];
					str = decodeURI(str);
					var strInput = str.split("!")[0];
					var strSearch = str.split("!")[1];
					$("#suggestId_end").val(strInput + "公交站");
					setTimeout(function() {
						if(window.plus) {
							plusReady(strSearch);
						} else {
							document.addEventListener("plusready", plusReady, false);
						}
					}, 500);

				}
			});

			function clickSearchBtn() {
				$("#research_btn").click();
			}

			$("#map_setUp").click(function() {
				//				$(this).hide();
				$("#map_setUp").slideToggle("fast");
			});
			$("#typeCar").select({
				title: "请选择您要查询的内容",
				items: [{
						title: "沿途收费站",
						value: "0"
					},
					{
						title: "沿途服务区",
						value: "1"
					},
					{
						title: "附近景点",
						value: "2"
					}
				],
				onOpen: function() {
					//弹窗打开时 显示遮罩层
					$("#opacityDiv").show();
				},
				onClose: function() {
					//弹窗关闭时 隐藏遮罩层
					$("#opacityDiv").hide();
					$("#map_setUp").show();
				},
				onChange: function(d) {
					$("#map_setUp").show();
					$("#typeCar b").html(d.titles);
					var k = d.values;
					map.clearOverlays();
					var Route = $("#routeCar b").html();
					var start = $("#suggestId_start").val();
					var end = $("#suggestId_end").val();
					if(Route == "最短时间") {
						var driving = new BMap.DrivingRoute(map, {
							renderOptions: {
								map: map,
								autoViewport: true
							},
							policy: routePolicy_driving[0]
						});
					} else if(Route == "最短距离") {
						var driving = new BMap.DrivingRoute(map, {
							renderOptions: {
								map: map,
								autoViewport: true
							},
							policy: routePolicy_driving[1]
						});
					} else if(Route == "避开高速") {
						var driving = new BMap.DrivingRoute(map, {
							renderOptions: {
								map: map,
								autoViewport: true
							},
							policy: routePolicy_driving[2]
						});
					}
					driving.search(start, end);
					pushMsgToMap(k);
				}
			});

			//点击图标显示详情
			function addClickHandler(content, marker, title) {
				var opts = {
					width: 120, // 信息窗口宽度
					title: title, // 信息窗口标题
				}
				marker.addEventListener("onclick", function(e) {
					var p = e.target;
					var point = new BMap.Point(p.getPosition().lng, p.getPosition().lat);
					var infoWindow = new BMap.InfoWindow(content, opts); // 创建信息窗口对象
					map.openInfoWindow(infoWindow, point); //开启信息窗口

				});
			};

			//★★★★★★★★★★★★★★★★★★★★★★★★
			//★★★★★点击查询按钮搜索路线（旧版）★★★
			//★★★★★★★★★★★★★★★★★★★★★★★★
			//			$("#research_btn").click(function() {
			//				if($("#suggestId_start").val() == "" && $("#suggestId_start").attr("placeholder") == "输入起点" || $("#suggestId_end").val() == "") {
			//					$.alert("请您输入起点和终点", "提示");
			//				} else {
			//					$(".loadingImgResult").show();
			//					var myPosition = $("#suggestId_start").attr("placeholder");
			//					if($("#bus").hasClass("weui_tab_bd_item_active")) {
			//						//当搜索公交时
			//						if(myPosition.indexOf("我的位置") != -1) {
			//							//当搜索起点为我的位置时
			//							var iframeUrl = "http://map.baidu.com/mobile/webapp/search/search/qt=bse&wd=" + $("#suggestId_end").val() +
			//								"&from=maponline&tn=m01&ie=utf-8&ptx=13951393.5&pty=5417598.93&name=我的位置&c=53&sc=53&ec=53&isSingle=true&bsetp=1&sn=1%24%24%24%2413951393.5%2C5417598.93%24%24我的位置%24%240%24%24%24%24&version=5&exptype=dep/tab=line&routeType=1";
			//						} else {
			//							var iframeUrl = "http://map.baidu.com/mobile/webapp/search/search/qt=bt&wd=长春市&from=maponline&tn=m01&ie=utf-8&sn=2%24%24%24%24%24%24" + $('#suggestId_start').val() +
			//								"%24%240%24%24%24%24&en=2%24%24%24%24%24%24" + $('#suggestId_end').val() + "%24%240%24%24%24%24&sc=53&ec=53&c=53&pn=0&rn=5&version=5&exptype=dep/tab=line&routeType=1";
			//						}
			//						$("#cxghIframe").attr("src", iframeUrl);
			//						showBaiduUrl();
			//					} else if($("#walk").hasClass("weui_tab_bd_item_active")) {
			//						//当导航栏位于步行检索时
			//						//					if($(".startPlace").children().length == "3") {
			//						if(myPosition.indexOf("我的位置") != -1) {
			//							//当起点输入框为我的位置时
			//							var iframeUrl = "http://map.baidu.com/mobile/webapp/search/search/qt=wse&wd=" + $("#suggestId_end").val() + "&from=maponline&tn=m01&ie=utf-8&c=53&sc=53&ec=53&isSingle=true&wsetp=1&sn=1%24%24%24%2413951794.11%2C5417309.69%24%24我的位置%24%240%24%24%24%24&version=3/tab=line&routeType=3&vt=map&traffic=off&evtson=off&universalLinkCbkTag=1";
			//						} else {
			//							var iframeUrl = "http://map.baidu.com/mobile/webapp/search/search/qt=walk&wd=吉林省&from=maponline&tn=m01&ie=utf-8&sn=2%24%24%24%24%24%24" + $("#suggestId_start").val() + "%24%240%24%24%24%24&en=2%24%24%24%24%24%24" + $("#suggestId_end").val() + "%24%240%24%24%24%24&sc=53&ec=53&c=53&pn=0&rn=5&version=3/tab=line&routeType=3&vt=map&traffic=off&evtson=off/?fromhash=1";
			//						}
			//						$("#cxghIframe").attr("src", iframeUrl);
			//						showBaiduUrl();
			//						//					$(".loadingImgResult").hide();
			//						//					}
			//
			//					} else if($("#car").hasClass("weui_tab_bd_item_active")) {
			//						//自驾
			//						var startStr = encodeURI($("#suggestId_start").val());
			//						var endStr = encodeURI($("#suggestId_end").val());
			//						if(myPosition.indexOf("我的位置") != -1) {
			//							//当起点输入框为我的位置时
			//							//							alert("走我的位置");
			//							var iframeUrl = "http://map.baidu.com/mobile/webapp/search/search/qt=nse&wd=" + $("#suggestId_end").val() +
			//								"&from=maponline&tn=m01&ie=utf-8&ptx=13951803.49&pty=5417311.45&name=我的位置&c=53&sc=53&ec=53&isSingle=true&nsetp=1&sn=1%24%24%24%2413951803.49%2C5417311.45%24%24我的位置%24%240%24%24%24%24&version=3/tab=line&routeType=2&vt=map&traffic=off&evtson=off&universalLinkCbkTag=1";
			//						} else {
			//							//							var iframeUrl = "http://map.baidu.com/mobile/webapp/search/search/qt=cur&wd=" + encodeURI("吉林省") + "&from=maponline&tn=m01&ie=utf-8/tab=line&routeType=2#search/search/qt=nav&wd=" + encodeURI("吉林省") + 
			//							//							"&from=maponline&tn=m01&ie=utf-8&sn=2%24%24%24%24%24%24" + startStr + "%24%240%24%24%24%24&en=2%24%24%24%24%24%24" + endStr + "%24%241%24%24"+encodeURI("吉林省")+"%24%24&sc=53&ec=53&c=53&pn=0&rn=5&version=3/tab=line&routeType=2&vt=map&traffic=off&evtson=off"
			//							var iframeUrl = "http://map.baidu.com/mobile/webapp/search/search/qt=nav&wd=吉林省&from=maponline&tn=m01&ie=utf-8&sn=2%24%24%24%24%24%24" + $("#suggestId_start").val() + "%24%240%24%24%24%24&en=2%24%24%24%24%24%24" + $("#suggestId_end").val() + "%24%240%24%24%24%24&sc=53&ec=53&c=53&pn=0&rn=5&version=3/tab=line&routeType=2&vt=map&traffic=off&evtson=off/?fromhash=1";
			//						}
			//						$("#cxghIframe").attr("src", iframeUrl);
			//						showBaiduUrl();
			//						$(".loadingImgResult").hide();
			//						var zhoubian = function() {
			//							$("#zbBtn").show();
			//						}
			//						setTimeout(zhoubian, 3000); //四秒后 周边按钮显示
			//
			//						if($("#suggestId_start").attr("placeholder").indexOf("我的位置") != -1) {
			//
			//						} else {
			//							var start = $("#suggestId_start").val();
			//							var end = $("#suggestId_end").val();
			//							var driving = new BMap.DrivingRoute(map, {
			//								renderOptions: {
			//									map: map,
			//									autoViewport: true
			//									//						panel: "myResult_car"
			//								},
			//								policy: 0
			//							});
			//							driving.search(start, end);
			//						}
			//					}
			//				}
			//
			//			});

			//			function baiduGetPath() {
			//				var pathStr = "";
			//				//				var pathArr = [];
			//				$.ajax({
			//					type: "post",
			//					url: "https://api.map.baidu.com/direction/v1",
			//					data: {
			//						"mode": "driving",
			//						"origin": $("#suggestId_start").val(),
			//						"destination": $("#suggestId_end").val(),
			//						"origin_region": "吉林",
			//						"destination_region": "吉林",
			//						"output": "json",
			//						"ak": "MMh4H9m5FLBpizlht86GnGynuaM0oGKz"
			//					},
			//					async: false,
			//					cache: false,
			//					dataType: "jsonp", //数据类型为jsonp
			//					success: function(data) {
			//						console.log(data.type);
			//						if(data.type == 1) {
			//							//当搜索无结果时
			//							$("#noResultCar").show();
			//						} else if(data.type == 2) {
			//							//当搜索有结果时
			//							$("#noResultCar").hide();
			//
			//						}
			//					},
			//					error: function(data) {
			//						$.alert("连接超时，请稍后再试", "提示");
			//					}
			//				});
			//			}

			//			// 百度地图API功能
			//			var routePolicy_transit = [BMAP_TRANSIT_POLICY_LEAST_TIME, BMAP_TRANSIT_POLICY_LEAST_TRANSFER, BMAP_TRANSIT_POLICY_AVOID_SUBWAYS];
			//
			var routePolicy_driving = [BMAP_DRIVING_POLICY_LEAST_TIME, BMAP_DRIVING_POLICY_LEAST_DISTANCE, BMAP_DRIVING_POLICY_AVOID_HIGHWAYS];
			//驾车规划
			function driving(d) {
				map.clearOverlays();
				var d = d ? d : 0;
				var start = $("#suggestId_start").val();
				var end = $("#suggestId_end").val();
				var route = routePolicy_driving[d.values];
				var driving = new BMap.DrivingRoute(map, {
					renderOptions: {
						map: map,
						autoViewport: true
						//						panel: "myResult_car"
					},
					policy: route
				});
				driving.search(start, end);
			};

			//自驾出行图层叠加 方法
			//			type = trip_planning_layer_cover
			//			TACTICS = 出行方案-- -- - 10 不高速 11 常规 12 距离短 13 不拥堵
			//			ORIGIN = 出发地
			//			DESTINATION = 目的地

			//选择类型 自驾
			$("#routeCar").select({
				title: "选择自驾查询方案",
				//				autoClose: true,
				items: [{
						title: "最短时间",
						value: 0 //BMAP_DRIVING_POLICY_LEAST_TIME,
					},
					{
						title: "最短距离",
						value: 1 //BMAP_DRIVING_POLICY_LEAST_DISTANCE,
					},
					{
						title: "避开高速",
						value: 2 //BMAP_DRIVING_POLICY_AVOID_HIGHWAYS",
					}
				],
				onOpen: function() {
					//弹窗打开时 显示遮罩层
					$("#opacityDiv").show();
				},
				onClose: function() {
					//弹窗关闭时 隐藏遮罩层
					$("#opacityDiv").hide();
					$("#map_setUp").show();
				},
				onChange: function(d) {
					$("#map_setUp").hide();
					$("#routeCar b").html(d.titles);
					map.clearOverlays();
					driving(d);
					getLineByCarCover();
					$("#typeCar b").html("查询详情"); //清空查询内容选项卡
					//					$("#typeCar").select(); //初始化查询内容选项卡
					//					if($("#typeCar b").html() == "沿途收费站") {
					//						pushMsgToMap(0);
					//					} else if($("#typeCar b").html() == "沿途服务区") {
					//						pushMsgToMap(1);
					//					} else if($("#typeCar b").html() == "附近景点") {
					//						pushMsgToMap(2);
					//					}

				}
			});

			var myValue;
			//清空桃心样式
			function clearTaoxin() {
				$("#suggestId_end_hidden").val(""); //清空隐藏的input
				$("#taoxin").html("&#xe649;");
				$("#taoxin").css("color", "#999999");
				$("#taoxin").removeClass("addCollect");
				$("#taoxin").next().hide(); //变回灰色不可点击桃心
			}

			$("#suggestId_end").one("focus", function() {
				clearTaoxin();
				ac_2 = new BMap.Autocomplete( //建立一个自动完成的对象
					{
						"input": "suggestId_end",
						"location": "吉林省"
					});
				ac_2.addEventListener("onhighlight", function(e) { //鼠标放在下拉列表上的事件
					var str = "";
					var _value = e.fromitem.value;
					var value = "";
					if(e.fromitem.index > -1) {
						value = _value.province + _value.city + _value.district + _value.street + _value.business;
					}
					str = "FromItem<br />index = " + e.fromitem.index + "<br />value = " + value;

					value = "";
					if(e.toitem.index > -1) {
						_value = e.toitem.value;
						value = _value.province + _value.city + _value.district + _value.street + _value.business;
					}
					str += "<br />ToItem<br />index = " + e.toitem.index + "<br />value = " + value;
					//				$("#searchResultPanel").innerHTML = str;
				});

				ac_2.addEventListener("onconfirm", function(e) { //鼠标点击下拉列表后的事件
					var _value = e.item.value;
					$("#suggestId_end").blur();
					myValue = _value.province + _value.city + _value.district + _value.street + _value.business;
					//				alert(myValue);
					if(localStorage.userJson) {
						$("#suggestId_end_hidden").val(myValue);
						$("#taoxin").css("color", "#FF0000");
						//显示可收藏字样
						$("#taoxin").next().html("可收藏");
						$("#taoxin").next().show();
						//					clearTimeout(timeout);
						yzCollect();
					}
					//				console.log($("#suggestId_end_hidden").val());
					//				$("#searchResultPanel").innerHTML = "onconfirm<br />index = " + e.item.index + "<br />myValue = " + myValue;
				});

			});

			//在输入终点输入框内点击键盘触发的事件
			var timeout;
			$("#suggestId_end").keyup(function() {
				clearTaoxin();
				//延时请求 验证所输入地点是否已收藏
				clearTimeout(timeout);
				timeout = setTimeout("yzCollect()", 1000);
			});
			//ajax验证请求方法
			function yzCollect() {
				if(localStorage.userJson) {
					var userName = JSON.parse(localStorage.userJson)[0].username;
					$.ajax({
						type: "post",
						url: Url,
						data: {
							"type": "end_collections_info",
							"USERNAME": userName
						},
						async: false,
						cache: false,
						dataType: "jsonp", //数据类型为jsonp
						jsonp: "callbackparam", //服务端用于接收callback调用的function名的参数  
						jsonpCallback: "jsonpCallback1",
						success: function(data) {
							//						console.log(eval(data.DATA));
							for(var i = 0; i < eval(data.DATA).length; i++) {
								if($("#suggestId_end").val() == eval(data.DATA)[i].ENDSTATION) {
									redTaoxin();
								}
							}
						},
						error: function(data) {
							//							$.alert("连接超时，请稍后再试", "提示");
						}
					});
				}

			};

			//变为红色桃心已收藏标记的方法
			function redTaoxin() {
				$("#taoxin").html("&#xe648;"); //当输入的内容和已收藏的地名一直时，提示已经收藏过
				$("#taoxin").css("color", "#FF0000");
				$("#taoxin").next().html("已收藏");
				$("#taoxin").next().show();
			}

			$("#suggestId_end").blur(function() {
				$("table").parent().hide();
			}).keyup(function() {
				$("table").parent().show();
			}).click(function() {
				this.focus();
				this.select();
			});
			//			$("#tangram-suggestion--TANGRAM__1f table").click(function(){
			//				$(this).hide();
			//			});
			function hasCollected() {
				$("#taoxin").html("&#xe648;");
				$("#taoxin").addClass("addCollect");
				$("#taoxin").next().show();
				$("#taoxin").next().html("已收藏"); //点击收藏桃心过后 显示为已收藏字样
			};
			//点击桃心（目的地收藏）按钮
			$("#collectionBtn").click(function() {
				if($("#suggestId_end_hidden").val() != "") {
					if(!$("#taoxin").hasClass("addCollect")) {
						hasCollected();
						//登录状态下进入本页 读取用户名
						var userName = JSON.parse(localStorage.userJson)[0].username;
						$.ajax({
							type: "post",
							url: Url,
							data: {
								"type": "end_collections",
								"USERNAME": userName,
								"ENDSTATION": $("#suggestId_end_hidden").val()
							},
							async: false,
							cache: false,
							dataType: "jsonp", //数据类型为jsonp
							jsonp: "callbackparam", //服务端用于接收callback调用的function名的参数  
							jsonpCallback: "jsonpCallback1",
							success: function(data) {
								//								console.log(data);
							},
							error: function(data) {
								$.alert("连接超时，请检查网络设置", "提示");
							}
						});
					}
				} else if(!localStorage.userJson) {
					$.confirm("收藏目的地，请先登录您的账号", function() {
						//点击确认后的回调函数
						if(!localStorage.cxghToLogin) {
							var cxghToLogin = "从出行规划跳转";
							var arr = [cxghToLogin];
							localStorage.cxghToLogin = JSON.stringify(arr);
						}
						window.location.href = "Login.html"; //跳转至登录页面
					}, function() {
						//点击取消后的回调函数
					});
				}

			});

			//当跳转至出行规划百度页面时 要隐藏的内容
			function showBaiduUrl() {
				$("#cxgh_Main").hide(); //隐藏出行规划我的页面主体部分
				$("#map_setUp").hide(); //隐藏出行规划驾车方式新增图层的选项层
				$("#getMyPosition").hide(); //隐藏右上角获取我的位置按钮
				$("#cxghIframe").show(); //显示搜索结果iframe
			};
			$("#myPosition_div").click(function() {
				//当点击到我的位置时 隐藏该div
				$(this).hide();
				$("#suggestId_start").attr("placeholder", "输入起点");
				$("#myPlaceSign").remove();
				$("#suggestId_start").focus();
			});

			//点击自驾中的搜周边按钮 方法
			$("#zbBtn").click(function() {
				$("#cxghIframe").hide();
				$("#l-map").show();
				$(this).hide();
				$("footer").hide(); //隐藏底部
				$("#returnCxgh").show(); //显示右上角返回按钮
				getView();
				//线路适应屏幕大小
				getLineByCarCover();
			});

			function getView() {
				//地址解析
				var myGeo = new BMap.Geocoder();
				var newPathArray = [];
				var start = $("#suggestId_start").val();
				var end = $("#suggestId_end").val();
				var p1;
				var p2;
				// 将起点地址解析结果显示在地图上
				myGeo.getPoint(start, function(point) {
					if(point) {
						//根据起终点坐标查询我的位置-我收藏的地点的线路规划
						p1_1 = Number(point.lng);
						p1_2 = Number(point.lat);
						p1 = new BMap.Point(p1_1, p1_2);
						console.log(p1);
						myGeo.getPoint(end, function(point) {
							if(point) {
								//根据起终点坐标查询我的位置-我收藏的地点的线路规划
								p2_1 = Number(point.lng);
								p2_2 = Number(point.lat);
								p2 = new BMap.Point(p2_1, p2_2);
								console.log(p2);
								newPathArray.push(p1, p2);
								console.log(newPathArray);
								map.setViewport(newPathArray);
							} else {
								alert("您选择地址没有解析到结果!");
							}
						});
					} else {
						alert("您选择地址没有解析到结果!");
					}

				});
			}
		</script>
	</body>

</html>